@Inject('$state', 'disclosureService', 'ngDialogService')
class technicalClarificaitonRegisterController {
  constructor() {
    this.data = {
      isEdit: false,
      activity: {
        name: '',
        startTime: '',
        organizer: '',
        site: '',
        speaker: '',
        recorder: '',
        content: '',
        technicalType: '',
        joinDepartment: '',
        attachmentId: null,
        files: [],
      },
    };
    this.view = {
      files: [],
    };
  }

  submitActivityForm() {
    const attachmentId = this.view.files.map(item => item.id);
    this.data.activity.attachmentIds = attachmentId;
    this.disclosureService.save(this.data.activity)
      .then((res) => {
        if (res.success) {
          this.ngDialogService.alertSuccess(res.message);
          this.$state.go('toDoSafeActivities');
        } else {
          this.ngDialogService.alertError(res.message);
        }
      });
  }

  reset() {
    this.data.activity = {};
  }
}

export default technicalClarificaitonRegisterController;
